package com.zzld.modules.sys.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zzld.core.service.BaseServiceImpl;
import com.zzld.modules.sys.entity.Login;
import com.zzld.modules.sys.mapper.LoginMapper;
import com.zzld.modules.sys.service.ILoginService;

@Service("loginService")
public class LoginServiceImpl extends BaseServiceImpl<Login> implements ILoginService {

	@Autowired
	private LoginMapper loginMapper;

	/**
	 * 查找用户是否可以登录
	 * 
	 * @param account
	 * @param passwd
	 * @return
	 */
	public Login findLoginUser(String account, String passwd) {
		Login login = new Login();
		login.setAccount(account);
		login.setPasswd(passwd);
		List<Login> list_login = loginMapper.select(login);
		if (list_login != null && list_login.size() > 0) {
			return list_login.get(0);
		}
		return null;
	}

	public int updateLoginUser(Login login) {
		if (login.getId() != null) {
			return (Integer) loginMapper.updateLoginByid(login);
		}
		return 0;
	}
}
